#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project : gtmsAutoTestProject 
@File    : print_api.py
@IDE     : PyCharm 
@Author  : Mario
@Date    : 2022/4/26 16:12 
@Describe:
"""
from APIs.posApi.base_pos_api import BasePosApi


class PrintAPI(BasePosApi):

    def __init__(self, brandCode, environment):
        super().__init__(brandCode, environment)

    def repair_table_order(self, orderNo):
        """
        补打台单
        :param orderNo:订单号
        :return:
        """
        payload = '{"orderNo":"' + orderNo + '"}'
        response = self.http_requests('order/printer/repair/table', payload)
        return response

    def order_print_bill(self, orderNo):
        """
        打印账单
        :param orderNo: 订单号
        :return:
        """
        payload = '{"orderNo":"' + orderNo + '"}'
        response = self.http_requests('order/printer/bill', payload)
        return response

    def order_print_repair_last(self, orderNo):
        """
        补打最末单
        :param orderNo:订单号
        :return:
        """
        payload = '{"orderNo":"' + orderNo + '"}'
        response = self.http_requests('order/printer/repair/last', payload)
        return response

    def order_bank_print(self, orderNo, customerId='9000000022'):
        """
        堂食-正向打印银单
        :param orderNo:订单号
        :param customerId:会员ID
        """
        payload = '{"orderNo":"' + orderNo + '","customerId":"' + customerId + '"}'
        response = self.http_requests('order/printer/bank', payload)
        return response

    def kitchen_list(self, orderNo):
        """
        获取订单下的厨单列表
        :param orderNo:订单号
        :return:
        """
        payload = '{"orderNo":"' + orderNo + '"}'
        response = self.http_requests('kitchen/list', payload)
        return response

    def kitchen_repair(self, traceId):
        """
        补打厨单
        :param traceId: traceId列表
        :return:
        """
        payload = '{"traceIds":["' + traceId + '"]}'
        response = self.http_requests('kitchen/repair', payload)
        return response

    def order_printer(self):
        """
        补打外卖单
        :return:
        """
        payload = '{"brandCode":"823882","date":1655164800000,"orderNo":"10000282233328","orderSource":5,"shopCode":"5999","thirdOrderNo":"52"}'
        response = self.http_requests('order/printer', payload)
        return response


if __name__ == '__main__':
    import time
    test = PrintAPI('823882', 'sit')
    i = 1
    while i < 30:
        i += 1
        test.order_printer()
        time.sleep(2)
